<template>
<table>
    <tr>
        <td>用户名</td>
        <td><input type="text" v-model="data.Uname"></td>
    </tr>
    <tr>
        <td>密码</td>
        <td><input type="password" v-model="data.Upwd"></td>
    </tr>
    <tr>
        <td><input type="button" value="登录" @click="Ulogin"></td>
    </tr>
</table>
</template>
<script setup lang="ts">
import axios from 'axios';
import {ref}from 'vue'
const data=ref(
    {
        Uname:'',
        Upwd:''
    }
)
const Ulogin=()=>{
    axios.get('https://localhost:44368/api/Lx/Ulogin',
        {
            params:{
                Uname:data.value.Uname,
                Upwd:data.value.Upwd
            }
        }
    ).then(
        (res)=>{
            console.log(res.data)
            if(res.data>0){
                alert('登录成功')
                return
            }else if(res.data==-2){
                alert('用户名不存在')
                return
            }else if(res.data==-1){
                alert('密码错误')
                return
            }else{
                alert('登录失败')
                return
            }
        }
    ).catch(
        (err)=>{
            console.log(err)
            alert('登录失败')
        }
    )
}


</script>